Q. VCI:1 Resolving undefined pco_State symbols A. The cause of the problem is that the .imp file has the same name as one of the .cpp files. So when .imp is schcomped into .cxx then compiled into .o, it will overwrite the .o file generated from the .cpp file; and hence the link error.
Q. VCI:2 Improving performance for schcomp for Windows/NT and Windows/95 A: The Versant header files in release 4.0.5 for NT/Win95 include the VC++ header file windows.h. This file in turn includes a lot of other VC++ header files. This causes schcomp to use up a lot of memory and to slow down quite a bit. Add the options -DWIN32_LEAN_AND_MEAN and -DWIN32EXTRA_LEAN to schcomp. These options will eliminate some of the non-essential include files and thus reduce the memory requirement and improve the performance of schcomp.
Q. VCI:3 Referential Integrity A. In a Versant/C++ application you can make use of BiLink/BiLinkVstr to establish a relationship for which referential integrity is ensured. If you delete an object in a BiLink relationship, the attribute (data memebr) of the other object in the BiLink relation will be set to NULL.
Q. VCI:4 Selecting on VTime A: Place a call to tzset() at the beginning of your program. tzset is a Standard C library function which initializes the global variables timezone ( of type time_t ) and daylight ( of type int).
Q. VCI:5 Differences between PObject::deleteobj() and PLink::deleteobj() A: The deleteobj() method in PObject calls the destructor for objects created with C++/Versant, while deleteobj() in Linkand LinkAny does not. PObject::deleteobj() calls PObject::operator delete(), which in turn calls the C++ destructor and PLink::deleteobj() as follows: PObject::deleteobj() | PObject::operator delete() / \ destructor Link::deleteobj() | o_deleteobj() Suppose you have a persistent class Foo, and foolink is a Link to a persistent Foo object created in C++/Versant: Link foolink = O_NEW_PERSISTENT (Foo)(); or Link foolink = new Persistent Foo (); Then foolink->deleteobj() would delete the persistent object pointed to by foolink from both memory and the database because the deleteobj() method called is in PObject. From the above diagram, we can see the destructor is called to delete the C++ Foo object from memory, and the C api o_deleteobj() deletes the Foo object from the database. In contrast, foolink.deleteobj() calls the deleteobj() method in Link. It only deletes the database Foo object with o_deleteobj(), but leaves the C++ Foo object in memory. Using this method in such manner leads to potential memory leak in the application.
Q. VCI:6 Usage of select_with_vstr for BiLinkVstr A: The key is to get to the LinkVstr attribute, uvstr, of BiLinkVstr. For example, class Departement : public PObject { ... BiLinkVstrstudents; ... } Then to use select_with_vstr on the "students" attribute of Department class, you need to specify the PAttribute as: PAttribute("Departement::students.PBiLinkVstr::uvstr)
Q. VCI:7 Indexes for VVSet A: VVSet::contains will make use of indexes if the elements added were added using the ::add method. If add_no_hash() is used no indexes are used and the search used for ::contains will be linear
Q. VCI:8 Usage of Persistent Templated classes A. Assume templateclass TestP:public PObject { ... }; main() { .... TestP *tp1 = new Presistent TestP (1); ... } This will fail as the linker looks for Versant elemental datatypes. Change int to o_u4b
Q. VCI:9 Checking for NULL within an embedded attribute A. Assume Object_B { private: RWCString description; } Object_A { private: Object_B objectB; } In this case, the attribute of object_B is not a reference type ( that is, a Link or a pointer) so it cannot be of null value.
Q. VCI:10 Building a DLL containing persistentclasses A. In Versant header file,each class declaration looks like class O_DLL_IMPORT_EXPORT PObject In the compile line, you can specify -DO_DLL_IMPORT_EXPORT=__declspec(dllexport) If you need further clarification, please refer to the NT 4.0.5 release notes on page 3-16.
Q. VCI:11 Iterators A Iterators are to be defined over static data only. For example, if an iterator is defined over the collection, no new data should be added to that collection. Iterators provide a mechanism that allows the user to traverse over a collection in an optimized manner. When an iterator is defined, Versant will allocated contiguous memory for the collection to make the iteration over the collection optimal. If data is added to the collection, the collection may be moved by Versant for optimization. Since iterators are in-memory pointers, derefercing of a the iterator may cause a coredump. The usage of the iterator should be as follows. An iterator should only be defined over a static collection. If the collection is to be dynamic, use a "for loop" to access the collection.
Q. VCI:12 Usage of PDOM:zapcods() A: PDOM::zapcods() or its C equivalent o_zapcods() is a very useful API which can be used to manage memory in the front end. It is also quite risky if not used correctly. You can use zapcods() to zap a COD (Cached Object Descriptor) entry as long as you are sure that: - no other dirty/new objects in your front end cache have references to the zapped COD. - the application does not access the COD again. In Versant/C++ LinkAny and Linkare abstractions for a COD entry.
Q. VCI:13 Copying objects to databases and preserving LOIDS A: Use o_migrateobjs() (PDOM::migrateobjs()) with O_MV_SYNC option to copy objects from one database to another. This option preserves the Logical Object ID (LOID) of the object. The semantics of this option is "move this object to target database, and keep a copy of it in the source database". So, in the session in which you actually call this API, the migrated (or "copied") objects can be accessed only in the target database. In order to force the aplication to access them in the source database you will have to zap the CODs for those objects and retrieve them from the source database.
Q. VCI:14 Definition of PClassObject_State A: Each persistent class (class deriving from PObject) in your application must have an instance of the template class PClassObject . So, if you have classes called "Car" and "Truck", both deriving from a persistent class "Vehicle", you should have PClassObject , PClassObject PClassObject , and PClassObject instantiated in your application. Normally, you do not have to worry about PClassObject or that of most Versant/C++ classes since they are pre-instatiated in the Versant/C++ library libcxxcls.a or libvcoll.a. PClassObject ::pco_State is a static member of PClassObject . This static data member holds information such as class layout, class signature etc. about a persistent class. This information is used for creating a persitent instance, bringing an instance of that class from the database and laying it out in memory and so on. It is instantiated and initialized during schema capture. In a CIH application, the macro O_CAPTURE_SCHEMA(type) in the implementation file causes the schema compiler to instantiate and initialize an instance of PClassObject and its pco_State static data member. Some of the causes for getting PClassObject ::pco_State as an unresolved symbol during linking are: 1. O_CAPTURE_SCHEMA for that persistent class is missing in the schema implementation file. 2. The schema definition file (the C++ file genrated by schema compiler) is missing on the link line.
Q. VCI:15 Query on an attribute of type VstrA. Vstr can be the target of a Query. Example: class BasicEmployee :public PObject { public: Vstr emp_id ; ... } Vstr mylist; PPredicate(PAttribute("BasicEmployee::emp_id") == (char *) (mylist.base()) ));
Q. VCI:16 Error 8001 when using a VVIDictionary A. This error can occur if you are trying to cast a pointer to a transient instance of a class and the constructor of the class does not contain the line VPP_CLASS_CONSTRUCTOR1(classname),which is needed for runtime type identification.
Q. VCI:17 Debbuging build time errors for cfront 3.0 applications A. a. Type in: setenv VPP_DEBUG 1 before starting the build process. b. Pass -ptv as an option to the linker in your makefile: This causes template instantiation to be done in verbose fashion. c. Look in the file with extension _err to see if any error messages get printed there.
©1996 Versant Object Technology 1380 Willow Road Menlo Park, CA 94025 USA
|
1-800-VERSANT Tel 415-329-7500 Fax 415-325-2380 e-mail info@versant.com |